/**
 * 
 */
package org.xlab.familystore.listener;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;

import org.xlab.familystore.InventoryActivity;
import org.xlab.familystore.db.DatabaseHelper;
import org.xlab.familystore.domain.Inventory;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;

import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
import com.j256.ormlite.dao.Dao;

/**
 * @author makubex
 * 
 */
public class BtnMyInventoryListener extends OrmLiteBaseActivity<DatabaseHelper>
		implements OnClickListener, Serializable {

	/**
	 * @serialField
	 */
	private static final long serialVersionUID = 5099068123783164810L;

	private static final String LOG_TAG = BtnMyInventoryListener.class
			.getSimpleName();

	/**
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	public void onClick(View v) {
		try {
			Log.d(LOG_TAG, "Button " + LOG_TAG + " was clicked!");
			@SuppressWarnings("unchecked")
			Dao<Inventory, Integer> inventoryDao = (Dao<Inventory, Integer>) getHelper()
					.getDao(Inventory.class);
			List<Inventory> list = inventoryDao.queryForAll();
			Log.d(LOG_TAG, "There are " + list.size()
					+ " results for 1st category.");
			Intent intent = new Intent();
			intent.setClass(v.getContext(), InventoryActivity.class);
//			intent.set
			super.startActivity(intent);
		} catch (SQLException e) {
			Log.e(LOG_TAG, "Database exception", e);
			return;
		}
	}

}
